package com.zdlyh.controller;

import com.zdlyh.domain.ResponseResult;
import com.zdlyh.domain.dto.UserDto;
import com.zdlyh.service.UserService;
import com.zdlyh.domain.vo.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/list")
    public ResponseResult<PageVo> getUserList(Integer pageNum, Integer pageSize, UserDto userDto){
        return userService.getUserList(pageNum,pageSize,userDto);
    }

    @PostMapping
    public ResponseResult addUser(@RequestBody UserDto userDto){
        return userService.addUser(userDto);
    }

    @GetMapping("/{id}")
    public ResponseResult getUserById(@PathVariable("id") Long id){
        return userService.getUserById(id);
    }

    @PutMapping
    public ResponseResult updateUser(@RequestBody UserDto userDto){
        return userService.updateUser(userDto);
    }

    @DeleteMapping("/{userIds}")
    public ResponseResult deleteUserById(@PathVariable List<Long> userIds){
        return userService.deleteUserById(userIds);
    }

    @PutMapping("/changeStatus")
    public ResponseResult changeStatus(@RequestBody UserDto userDto){
        return userService.changeStatus(userDto);
    }
}
